Lab 01 - Introduction to Linux
Introduction to Linux

1. Activity Identity
| Activity title | Introduction to Robotics |
|---|---|
| Topic | Linux / Robotics / IoT |
| Authors | Institute of Robotics and Machine Intelligence Dominik Belter, Jakub Chudzinski, Marcin Czajka, Kamil MΕodzikowski |
| Target learners | Bachelor (Computer Science / IT, Robotics) |
| Estimated duration | 1.5 hour |
| Difficulty level | Beginner |
| FOSSBot environment | Linux workstation |
| Licence | CC BY 4.0 |
2. Learning Objectives and Competences
| ID | Learning outcome | Related competences | Assessment evidence |
|---|---|---|---|
| LO1 | Students will be able to work efficiently in the Linux terminal
using autocompletion, history, command chaining and built-in help
(--help, man). |
Linux operating system knowledge; gathering and interpreting information from documentation | Screenshot of the IPv4 address from Task 2.1 (Submission item 1) |
| LO2 | Students will be able to manage files and directories from the
command line (including wildcards) and edit text files in
nano and vim. |
Linux operating system knowledge; selecting programming tools essential for working with a robot | Screenshot of the time vim output from Task 4.2 (Submission item 2) |
| LO3 | Students will be able to connect to another lab workstation over SSH
and transfer files with scp and rsync. |
Linux operating system knowledge; selecting programming tools essential for working with a robot | Screenshots of the SSH session and remote ls (Submission items 3 and 4) |
3. Prerequisites
A workstation running Linux with a working network connection.
Basic computer literacy: comfortable using a keyboard and mouse, opening applications, capturing screenshots.
4. Required Material and Setup
| Category | Item | Version / Quantity | Notes |
|---|---|---|---|
| Hardware | Workstation | 1 per student | Any Linux PC. |
| Software | OpenSSH client, rsync, nano,
vim |
bundled with most Linux distributions | Pre-installed on the lab workstations. |
| Software | tree |
installed during Task 5.1 | Installed via sudo apt install tree as part of the
lab. |
5. Safety, Ethics and Accessibility Notes
The only risks in this lab are operational:
Commands run with
sudo(especiallyrm -r) can permanently delete data. Always re-read a destructive command before pressing Enter.systemctl poweroffandsystemctl rebootwill end any unsaved work on the target machine. If you are connected via SSH to a remote machine, these commands affect the remote, not your workstation.
6. Scenario and Problem Statement
During this laboratory you will work with a remote machine - another workstation in the lab. You will reach it from the terminal of your own workstation over the network. The same techniques you learn here will be used in later labs to connect to a FOSSBot (a small mobile robot built around a Raspberry Pi).
7. Lab Workflow
| Phase | Student action | Expected output | Time |
|---|---|---|---|
| 1. Prepare | Log in and open a terminal | Working shell | 5 min |
| 2. Terminal basics | Practice autocompletion, history, help; explore ip via
man |
Familiarity with man, --help,
Ctrl-R |
15 min |
| 3. Files | Copy, move, delete, create files; use wildcards | A scratch directory populated and cleaned up | 20 min |
| 4. Text editors | Edit a file in both nano and vim |
A modified text file | 15 min |
| 5. Packages | Install a package with apt |
Installed package | 7 min |
| 6. Remote access | SSH, transfer files with scp/rsync, shut
down a remote machine |
Active SSH session, files transferred, shutdown executed | 28 min |
8. Step-by-Step Instructions
Step 1 - Environment preparation
π‘ Lab workstation credentials. Every workstation in the lab uses the same local account: username
put, passwordlrm. Use these credentials to log in to your machine, and the same pair to SSH into another machine in the lab in Step 6.
Log in to your lab workstation.
Open a terminal (
Ctrl+Alt+Ton Ubuntu).
Expected result: A terminal window is open and the
prompt looks similar to put@host:~$.
Step 2 - Terminal basics
The three commands you will use most often to find your way around the filesystem:
pwd- prints the current working directory (where you are now).ls- lists the files and directories in the current directory.ls -ladds detailed information;ls -ashows hidden files (those starting with.).cd <path>- changes the working directory.cd ~goes to your home directory,cd ..goes up one level,cd -returns to the previous directory.
Try them now:
pwd
ls
cd /tmp
pwd
cd ~Once you can move around, the shortcuts below make every command faster.
- Tab completion. Start typing a command or path and
press
Tab. If a single completion exists, the shell finishes the word for you. If several completions are possible, pressTabtwice to list them. Try:
cd /us<Tab>History. Use the
Up/Downarrow keys to walk through the commands you have already run in this session. For older history, pressCtrl+Rand start typing - the shell will incrementally search backwards.Re-running the previous command.
!!expands to the last command you ran. The classic example is forgettingsudo:
apt update # fails: permission denied
sudo !! # re-runs as: sudo apt update- Chaining commands. Use
&&to run a second command only if the first succeeds, and;to run a second command regardless. For example:
mkdir scratch && cd scratchvs.
mkdir scratch ; cd scratchClearing the screen.
clear(orCtrl+L) wipes the visible terminal.Built-in help. Almost every command supports
--helpfor a short reference:
ls --helpFor a longer manual, use man:
man lsman opens a pager - a read-only viewer that
fills the terminal. While the pager is open, your terminal does not
accept normal shell commands; instead it reacts to single-key
commands:
q- quit the pager and return to the shell prompt. This is how you get out.SpaceorPageDown- scroll one page downborCtrl+BorPageUp- scroll one page upUp/Downarrows - scroll one line at a time/then type text thenEnter- search forward for the text you typed; pressnto jump to the next match,Nfor the previous one?then type text thenEnter- same as/but searches backward
π‘ Tip: Searching inside
manis the fastest way to jump straight to a section of interest. For example,/EXAMPLESfollowed byEnterjumps to the EXAMPLES section of any manual page.
Task 2.1
The ip command prints information about network
interfaces (your IP address, MAC address, link state). You will need it
whenever you debug a network problem on any machine you SSH into. Open
its manual page with man ip and use the EXAMPLES
section to find a command that prints only the IPv4 addresses of all
interfaces. Run it on your workstation.
Expected result: You can move between commands with
the arrow keys, complete paths with Tab, and you have read
the ip manual far enough to identify a relevant
example.
πΈ Capture for submission: screenshot the terminal output that shows your IPv4 address. Press
Print Screento take a screenshot; files are saved to~/Pictures/Screenshots/.
Step 3 - Managing files and directories
The basic file-manipulation commands all share a similar shape:
command [flags] source destination.
- Clean up state from any previous lab session and create a fresh scratch directory. Remove leftover screenshots and any leftover work, then create a new empty scratch directory:
rm -rf ~/Pictures/Screenshots /tmp/linux-lab && mkdir /tmp/linux-labπ‘ Tip: Like most file commands,
rmaccepts multiple paths in one call - that is why we can clear both directories with a singlerm. The&&then only runsmkdirifrmsucceeded - which is the safety chain you read about in Step 2.All lab work happens in
/tmp/linux-labrather than in your home directory./tmpis the conventional location for scratch work and is wiped on every reboot, so the workstation stays clean for the next user.
- Enter the scratch directory and verify with
pwd:
cd /tmp/linux-lab
pwdThe expected output of pwd is
/tmp/linux-lab.
- Create empty files with
touch:
touch note.txt report.txt data.csv- Copy a file to a new name:
cp note.txt note-backup.txtFor entire directory trees, add -r (recursive):
cp -r /tmp/linux-lab /tmp/linux-lab-copy- Move or rename a file with
mv:
mv note-backup.txt archived-note.txtIf the second argument is an existing directory, mv
moves the file into it instead of renaming.
- Delete files with
rm. Use-rfor directories. Be careful - this operation is irreversible (files are not moved to a recycle bin).
rm archived-note.txt
rm -r /tmp/linux-lab-copy- Wildcards (globs) let you act on many files at once:
*matches any sequence of characters (including none)?matches exactly one character[abc]matches one character from the set[^abc]matches one character not in the set
Examples:
cp *.txt /tmp/ # copy every .txt file from the current dir to /tmp
rm /tmp/linux-lab/[0-9]* # delete files in the scratch dir whose name starts with a digitπ‘ Tip: Before running a destructive command with a glob, replace
rmwithlsfirst. Ifls *.txtlists what you expected, thenrm *.txtwill delete exactly those files.
Task 3.1
Inside /tmp/linux-lab, create the files
log1.txt, log2.txt, log3.txt,
data.csv and image.png. Using a
single rm command with a glob, delete only the
.txt files.
Expected result: After Task 3.1,
ls /tmp/linux-lab shows only data.csv and
image.png.
Step 4 - Text editors in the terminal
Whenever you SSH into a remote machine, you have no GUI and must edit
files from the terminal. Two editors are universally available:
nano (simple, menu-driven) and vim (powerful,
modal).
Nano
nano is the right choice for the occasional edit. Open
or create a file with:
nano note.txtThe most important shortcuts are listed at the bottom of the screen. The essentials:
Ctrl+O- save (Write Out)Ctrl+X- exitCtrl+K- cut the current lineCtrl+U- paste
Vim
vim is faster once you know it, but it is modal
- there is a separate mode for moving the cursor and a separate mode for
typing text. Open a file with:
vim note.txtModes:
i- enter Insert mode before the cursor (insert)a- enter Insert mode after the cursor (append - one character to the right)A- jump to the end of the current line and enter Insert mode (this is how you add text at the end of a line)o- open a new line below the current one and enter Insert mode (combined withG- jump to the last line - this is how you append to the end of a file)O- open a new line above the current one and enter Insert modeEsc- leave Insert mode (return to Normal mode, where keys are commands)
Commands (typed in Normal mode, confirmed with
Enter):
:w- save:q- quit:q!- quit without saving:x- save and quit
π‘ Tip: If you find yourself stuck in vim, press
Esca few times and then type:q!followed byEnter. That always gets you out without saving.
Task 4.1
Use vim to add a single line of text to
/tmp/linux-lab/note.txt, save and quit.
Task 4.2
Re-open the same file with time to measure how long the
whole editing session takes:
time vim /tmp/linux-lab/note.txtAdd another line, save and quit. The time output reports
real, user and sys durations.
Expected result: note.txt contains the
lines you typed, and the time command printed a
real duration of a few seconds.
πΈ Capture for submission: screenshot the terminal output showing the
timeline withreal/user/sysdurations.
Step 5 - Installing
packages with apt
On Ubuntu, software is installed from central repositories with
apt. Avoid installing software by downloading
.run files from random websites - apt keeps
everything tracked and updatable.
The most common operations:
sudo apt update # refresh the list of available packages
apt search <keyword> # find a package by name or description
sudo apt install <package-name> # install a package
sudo apt remove <package-name> # uninstall a packageTask 5.1
Read the output of apt --help. Then search for the
package tree, remove any version left over from a previous
session and install it:
apt search tree
sudo apt remove -y tree # cleanup from a previous session (harmless if tree is not installed)
sudo apt install treeπ‘ Tip: If
treewas not installed yet, theremovestep will printPackage 'tree' is not installed, so not removedand exit cleanly. The operation is idempotent - it leaves the system in the same state regardless of whether the package was there.
Confirm the install by running tree on the scratch
directory you created in Step 3:
tree /tmp/linux-labExpected result: tree prints a small
directory tree similar to:
/tmp/linux-lab
βββ data.csv
βββ image.png
βββ note.txt
1 directory, 3 files
Step 6 - Remote access to another machine
In this step you will connect from your own terminal to another workstation in the lab and run commands on it as if you were sitting at it.
Connecting with ssh
The ssh command opens an interactive shell on a remote
machine:
ssh <user>@<remote-ip>Throughout this lab, replace <remote-ip> with the
IPv4 address of another lab workstation - you will obtain it in Task 6.1. Every lab workstation has the same local
put account (with the password from Step 1), so
put is the username you authenticate as on the remote
machine.
So to log in as user put on a remote machine:
ssh put@<remote-ip>If the remote username is the same as your local username, you may omit it:
ssh <remote-ip>π‘ Tip: The first time you connect to a new host, SSH asks you to verify the hostβs fingerprint. Type
yesto continue. This protects you from connecting to an imposter on subsequent sessions.
Task 6.1
Get the IPv4 address of another workstation in the lab (ask whoever
is using it). Connect to it with SSH (account: put,
password: lrm). Once connected, run whoami and
hostname to confirm you are on the remote machine. Then end
the session with exit.
πΈ Capture for submission: while you are connected, take a screenshot of the terminal - the prompt should show the remote hostname, not your own.
Transferring files with
scp
scp (secure copy) has the same shape as cp,
but the source or destination can be on a remote machine. The remote
path uses the syntax
<user>@<address>:<path>:
π‘ Tip:
scpopens its own SSH connection to the remote machine to do the transfer. Run it from your local terminal, exactly as you run any local command - do not ssh to the remote first. The connection lives only for the duration of the copy and closes automatically when the transfer finishes.
# upload a single file
scp local-file.txt put@<remote-ip>:~/
# upload a whole directory
scp -r local-directory put@<remote-ip>:~/
# download a single file
scp put@<remote-ip>:~/remote-file.txt ./
# download a whole directory
scp -r put@<remote-ip>:~/remote-directory ./Task 6.2
Download any file from the remote machine into
/tmp/linux-lab/ using scp. Edit it locally
(with nano or vim) and upload it back to the
remote machine under a new name. Verify the new file is there by SSH-ing
in and running ls.
πΈ Capture for submission: screenshot the
lsoutput on the remote machine showing the file you uploaded back.
Transferring files with
rsync
rsync is incremental - it only sends the parts of files
that have changed, and it can resume interrupted transfers. This makes
it the right tool for moving large directories (such as datasets or log
files) to and from a remote machine. A reasonable default
invocation:
rsync -PHAXphax <local_directory> <user>@<address>:<target_directory>
rsync -PHAXphax <user>@<address>:<remote_file> <local_directory>Task 6.3
Look up what each flag in -PHAXphax does (start with
man rsync and search for each letter). Then use
rsync to copy a directory to the remote machine.
Power management with
systemctl
Most modern Linux distributions use the systemd init
system. The same systemctl command shuts down, reboots and
suspends the machine:
systemctl poweroff- power off the machinesystemctl reboot- reboot the machinesystemctl suspend- suspend (sleep) the machine
The first two also have short aliases: poweroff and
reboot.
Task 6.4
Ask a classmate at the neighboring station for their IPv4 address. SSH into their computer and shut it down:
sudo systemctl poweroffYou will need to type the put password again because of
sudo. The remote machine shuts down within a few seconds
and your SSH session drops - that is the expected outcome.
Expected result: You have opened at least one SSH
session to a remote machine, successfully transferred a file in both
directions using scp and a directory using
rsync, and finally shut down the remote workstation with
sudo systemctl poweroff.
9. Analysis Questions
Which of the techniques from Step 2 (
Tab,Ctrl+R,!!, command chaining) saved you the most keystrokes during this lab? Give a concrete example.What is the practical difference between
scp -r foo barandrsync -PHAXphax foo barwhen you copy a 500 MB directory and the network drops halfway through?You want to copy
/tmp/linux-lab/note.txtfrom your local workstation to~/on a remote machine. From which terminal do you runscp- your own local terminal, or one that is already SSH-ed into the remote? Justify briefly.List two commands from this lab that needed
sudo. In each case, what would the system do if you ran the command withoutsudo?
10. Submission Requirements
A screenshot of the terminal showing the IPv4 address found in Task 2.1.
A screenshot of the
time vimoutput from Task 4.2 showing thereal/user/sysdurations.A screenshot of an active SSH session from Task 6.1 (the prompt should show the remote hostname, not your own).
A screenshot of
lson the remote machine after Task 6.2, showing the file you uploaded back.Short answers (2-3 sentences each) to the four analysis questions.
11. References and Open Licence
manpages forip,cp,mv,rm,ssh,scp,rsync,systemctl,apt.- Ubuntu Server Guide - https://ubuntu.com/server/docs.
- FOSSBot project - https://fossbot.org.
The Creative Commons Attribution 4.0 International (CC BY 4.0) license allows users to share, copy, distribute, and adapt the work, even for commercial purposes, as long as proper credit is given to the original creator.
EU funding disclaimer
Funded by the European Union. Views and opinions expressed are however those of the author(s) only and do not necessarily reflect those of the European Union or the European Education and Culture Executive Agency (EACEA). Neither the European Union nor EACEA can be held responsible for them.